//
//  CYStateOneViewController.m
//  cyydt
//
//  Created by chu on 2019/1/21.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYStateOneViewController.h"
#import "CYStateTwoViewController.h"

@interface CYStateOneViewController ()
{
    NSString *_type;
}
@property (weak, nonatomic) IBOutlet UIButton *button1;
@property (weak, nonatomic) IBOutlet UIButton *button2;
@property (weak, nonatomic) IBOutlet UIButton *button3;
@property (weak, nonatomic) IBOutlet UIButton *button4;
@property (weak, nonatomic) IBOutlet UIButton *doneBtn;
@property (weak, nonatomic) IBOutlet UIView *backView;

@end

@implementation CYStateOneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showYinDao"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    
    self.title = @"状态";
    _type = @"0";
    self.doneBtn.layer.cornerRadius = self.doneBtn.frame.size.height / 2;
//    self.doneBtn.layer.masksToBounds = YES;
    self.backView.layer.cornerRadius = 10;
    [self dropShadowWithOffset:CGSizeMake(0, 0)
                        radius:5
                         color:[UIColor blackColor]
                       opacity:0.14];
    
    [self.button1 setTitle:@"创业失败，思考中" forState:UIControlStateNormal];
    [self.button1 setTitleColor:RGBOF(0x666666) forState:UIControlStateNormal];
    [self.button1 setTitleColor:RGBOF(0x333333) forState:UIControlStateSelected];

    [self.button2 setTitle:@"我想创业，规划中" forState:UIControlStateNormal];
    [self.button2 setTitleColor:RGBOF(0x666666) forState:UIControlStateNormal];
    [self.button2 setTitleColor:RGBOF(0x333333) forState:UIControlStateSelected];
    
    [self.button3 setTitle:@"正在创业，奋斗中" forState:UIControlStateNormal];
    [self.button3 setTitleColor:RGBOF(0x666666) forState:UIControlStateNormal];
    [self.button3 setTitleColor:RGBOF(0x333333) forState:UIControlStateSelected];
    
    [self.button4 setTitle:@"创业成功，数钱中" forState:UIControlStateNormal];
    [self.button4 setTitleColor:RGBOF(0x666666) forState:UIControlStateNormal];
    [self.button4 setTitleColor:RGBOF(0x333333) forState:UIControlStateSelected];
    
    [self rightBarItemWithTitle:@"跳过"];
}

- (void)RighttouchEvent{
    [[AppDelegate sharedAppDelegate] enterRootVc];
}

- (void)dropShadowWithOffset:(CGSize)offset
                      radius:(CGFloat)radius
                       color:(UIColor *)color
                     opacity:(CGFloat)opacity {
//    CGMutablePathRef path = CGPathCreateMutable();
//    CGPathAddRect(path, NULL, self.backView.bounds);
//    self.backView.layer.shadowPath = path;
//    CGPathCloseSubpath(path);
//    CGPathRelease(path);
    
    self.backView.layer.shadowColor = color.CGColor;
    self.backView.layer.shadowOffset = offset;
    self.backView.layer.shadowRadius = radius;
    self.backView.layer.shadowOpacity = opacity;
    self.backView.clipsToBounds = NO;
}

- (IBAction)selAction:(UIButton *)sender {
    if (sender == self.button1) {
        self.button1.selected = YES;
        self.button1.titleLabel.font = [UIFont systemFontOfSize:19];
        
        self.button2.selected = NO;
        self.button2.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button3.selected = NO;
        self.button3.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button4.selected = NO;
        self.button4.titleLabel.font = [UIFont systemFontOfSize:17];
        
        _type = @"1";
    }
    if (sender == self.button2) {
        self.button1.selected = NO;
        self.button1.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button2.selected = YES;
        self.button2.titleLabel.font = [UIFont systemFontOfSize:19];
        
        self.button3.selected = NO;
        self.button3.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button4.selected = NO;
        self.button4.titleLabel.font = [UIFont systemFontOfSize:17];
        
        _type = @"2";
    }
    if (sender == self.button3) {
        self.button1.selected = NO;
        self.button1.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button2.selected = NO;
        self.button2.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button3.selected = YES;
        self.button3.titleLabel.font = [UIFont systemFontOfSize:19];
        
        self.button4.selected = NO;
        self.button4.titleLabel.font = [UIFont systemFontOfSize:17];
        
        _type = @"3";
    }
    if (sender == self.button4) {
        self.button1.selected = NO;
        self.button1.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button2.selected = NO;
        self.button2.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button3.selected = NO;
        self.button3.titleLabel.font = [UIFont systemFontOfSize:17];
        
        self.button4.selected = YES;
        self.button4.titleLabel.font = [UIFont systemFontOfSize:19];
        
        _type = @"4";
    }
    
}

- (IBAction)doneAction:(id)sender {
    if ([_type isEqualToString:@"0"]) {
        [self.view makeToast:@"请选择创业时期" duration:1.5 position:CSToastPositionCenter];
        return;
    }
    CYStateTwoViewController *two = [[CYStateTwoViewController alloc] init];
    two.type = _type;
    [[AppDelegate sharedAppDelegate] pushViewController:two];
}


@end
